package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CombineTwoStringArray {
	public static void main(String[] argv) throws Exception {
		String[] array = new String[]{"1", "abc", "level", null,
				"www.tah1986.com", "asdf 123"};
		String str = "www.tah1986.com";
		System.out.println(java.util.Arrays.toString(addStringToArray(
				array, str)));
	}

	public static String[] addStringToArray(final String[] array,
	                                        final String str) {

		if (array.length == 0)
			return new String[]{str};

		final String[] newArr = new String[array.length + 1];
		System.arraycopy(array, 0, newArr, 0, array.length);
		newArr[array.length] = str;
		return newArr;
	}
}
